package edu.asu.sefcom.extract.profile.data;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
import java.util.List;
import java.util.Properties;

import org.apache.log4j.Logger;

import scala.actors.threadpool.Arrays;

public class Util {
	
	public static void main(String[] args){
		System.out.println(getYearList());
	}
	
	public static List<String> getYearList(){
		Properties properties = new Properties();
		try {
			properties.load(new FileInputStream("config/app.properties"));
		} catch (IOException e) {
		}
		String yearList = "" + properties.getProperty("edu.asu.cidse.sefcom.crimenet.indexing.yearlist");
		String[] list1=yearList.split("[,]");
//		Logger.getLogger(Util.class).warn(list1);
		return Arrays.asList(list1);
	}
	
	public static String readFile(String fileName)
			throws IllegalArgumentException {
		String docData = "";
		FileInputStream inStream = null;
		try {
			File file = new File(fileName);
			String charsetName = "UTF-8";
			inStream = new FileInputStream(file);
			MappedByteBuffer byteData = inStream.getChannel().map(
					FileChannel.MapMode.READ_ONLY, 0, file.length());
			docData = Charset.forName(charsetName).decode(byteData).toString();
			inStream.close();
		} catch (Exception e) {
			throw new IllegalArgumentException(e);
		}

		Logger.getLogger(Util.class).debug("---$$$---" + docData);
		return docData;
	}
}
